using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyScript : MonoBehaviour
{
    private HeroScript hero;

    void Start()
    {
        //获取collider组件
        // var collider = GetComponent<Collider2D>();
        // collider.isTrigger = true;
        // Debug.Log(collider);
    }
    public void SetHero(HeroScript hero)
    {
        this.hero = hero;
    }
    public void Move()
    {
        float dt = Time.deltaTime;
        float speed = 0.5f;
        //敌人向hero移动
        Vector3 direction = hero.GetPosition() - transform.position;
        transform.position += direction.normalized * speed * dt;
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        // 示例代码：打印信息并可能执行其他逻辑
        Debug.LogFormat("Object {0} has entered the trigger!", other.gameObject.name);

        // 根据需要进行进一步的逻辑处理，比如交换数据、播放动画或更改状态等
    }
}
